const axios = require('axios')
var _baseUrl = '/gateway/business/api'

// 登录
export function login (data) {
  const url = _baseUrl + '/login' + data
  return axios.post(url, {}, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 退出
export function logOut () {
  const url = _baseUrl + '/logOut'
  return axios.post(url, {}, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 验证用户token是否有效
export function checkToken () {
  const url = _baseUrl + '/checkToken'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取Session
export function getSession (data) {
  const url = _baseUrl + '/getSession'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取功能浏览记录信息
export function getBrowseRecord (query) {
  const url = _baseUrl + '/browseRecord/get' + query
  return axios.get(url, query).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 添加功能浏览记录信息
export function insertBrowseRecord (query) {
  const url = _baseUrl + '/browseRecord/insert' + query
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}
